<template>
  <div>
    <form>
      <label>姓名：</label>
      <input type="text" v-model="uname" /><br /><br />

      <label>年龄：</label>
      <input type="number" v-model.number="age" /><br /><br />

      <label>身高：</label>
      <input type="text" v-model.number="height" />(米)<br /><br />

      <label>体重：</label>
      <input type="number" v-model.number="weight" />(公斤)<br /><br />

      <label>病史：</label>
      <input type="text" v-model="sickHistory" /><br /><br />

      <button @click.prevent="submit">诊断</button>
    </form>

    <p v-show="isShow">患者 {{ uname }} 的诊断结果：{{ res }}</p>
  </div>
</template>

<script>
export default {
  data() {
    return {
      uname: '',
      age: '',
      height: '',
      weight: '',
      sickHistory: '',
      res: '',
      isShow: false,
    }
  },
  methods: {
    submit() {
      this.isShow = !this.isShow
      const BMI = this.weight / (this.height * this.height)
      if (BMI < 18.5) {
        this.res = '过轻'
      }
      if (BMI > 23.9) {
        this.res = '过重'
      } else this.res = '正常'
    },
  },
}
</script>
